﻿using Domain.Base;
using Domain.Entity;
using DtoFw.Enum;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace Service
{
    ///<summary>
    ///案件
    ///</summary>
    [SugarTable("case_physical_pandian")]
    [DB(EnumDatabase.Mysql, Cache = false)]
    public class CasePhysicalPanDianEntity : BaseEntity
    {   
        /// <summary>
        /// 部门id
        /// </summary>
        public long OrganId { get; set; }
        /// <summary>
        /// 盘点标题
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 案件id
        /// </summary>
        public long CaseId { get; set; }
        /// <summary>
        /// 状态
        /// 0：待同步
        /// 1：已同步
        /// 2：已盘点
        /// </summary>
        public int Status { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        /// <summary>
        /// 物证明细
        /// </summary>
        public string Attrs { get; set; }
        public List<CasePhysicalPanDianAttrEntity> _Items;
        [SqlSugar.SugarColumn(IsIgnore = true)]
        /// <summary>
        /// 物证明细
        /// </summary>
        public List<CasePhysicalPanDianAttrEntity> Items
        {
            get
            {
                if(_Items == null)
                {
                    if (string.IsNullOrEmpty(this.Attrs))
                    {
                        _Items = new List<CasePhysicalPanDianAttrEntity>();
                    }
                    else
                    { 
                        _Items = Newtonsoft.Json.JsonConvert.DeserializeObject<List<CasePhysicalPanDianAttrEntity>>(Attrs);
                    }
                }
                return this._Items;
            }
        }
    }

    public class CasePhysicalPanDianAttrEntity
    {
        /// <summary>
        /// 物证id
        /// </summary>
        public long id { get; set; }
        /// <summary>
        /// 盘点状态
        /// 0:离库
        /// 1:在库
        /// </summary>
        public int st { get; set; }
    }

    public class PanDianTaskEntity
    {
        /// <summary>
        /// 任务名称
        /// </summary>
        public string name { get; set; }
        /// <summary>
        /// 任务类型（0盘点1搜寻）
        /// </summary>
        public int type { get; set; }
        /// <summary>
        /// 任务唯⼀id
        /// </summary>
        public string relationId { get; set; }
        /// <summary>
        /// 计划时间(yyyy-MM-dd HH:mm:ss)
        /// </summary>
        public string planTime { get; set; }
        
        /// <summary>
        /// 任务明细
        /// </summary>
        public List<PanDianTaskDetailEntity> details { get; set; }
    }

    public class PanDianTaskDetailEntity
    {
        /// <summary>
        /// 标签编号
        /// </summary>
        public string epc { get; set; }
        /// <summary>
        /// 名称
        /// </summary>
        public string name { get; set; }
        /// <summary>
        /// 存放位置
        /// </summary>
        public string address { get; set; }
        /// <summary>
        /// 盘点状态
        /// 0：离库
        /// 1：在库
        /// </summary>
        public int status { get;set;}
    }

}
